/*
package com.example.liuke.guangguang.untils;

import android.content.Context;
import android.widget.Toast;

import com.example.liuke.guangguang.bean.mseeagebean;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

*/
/**
 * Created by liuke on 2017/12/13.
 * 一种是去读本地的 一种根据流来读取的
 *//*

*/
/*switch (hssfCell.getCellType()) {
                                    case HSSFCell.CELL_TYPE_NUMERIC: // 数字
                                        cellValue = hssfCell.getNumericCellValue() + "";
                                        break;
                                    case HSSFCell.CELL_TYPE_STRING: // 字符串
                                        cellValue = hssfCell.getStringCellValue();
                                        break;
                                    case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean
                                        cellValue = hssfCell.getBooleanCellValue() + "";
                                        break;
                                    case HSSFCell.CELL_TYPE_FORMULA: // 公式
                                        cellValue = hssfCell.getCellFormula() + "";
                                        break;
                                    case HSSFCell.CELL_TYPE_BLANK: // 空值
                                        cellValue = "";
                                        break;
                                    case HSSFCell.CELL_TYPE_ERROR: // 故障
                                        cellValue = "非法字符";
                                        break;
                                    default:
                                        cellValue = "未知类型";
                                        break;*//*


public class POI {
    private Context context;
    private List<mseeagebean> list;

    public POI(Context context) {
        super();
        this.context = context;
    }

    //根据地址来读取execl
    public List<mseeagebean> readexcel(String execlpath) {
        list = new ArrayList<>();
        list.clear();
        if (isfileexit(execlpath)) {
            //执行相关操作
            if (execlpath.endsWith("xls")) {
                HSSFWorkbook hssfWorkbook = null;
                try {
                    InputStream is = new FileInputStream(execlpath);
                    hssfWorkbook = new HSSFWorkbook(is);
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                list = readxls(hssfWorkbook);
            } else if (execlpath.endsWith("xlsx")) {
                XSSFWorkbook xssfWorkbook = null;
                try {
                    InputStream is = new FileInputStream(execlpath);
                    xssfWorkbook = new XSSFWorkbook(is);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                //list=read(xssfWorkbook);
            }
        }
        return list;
    }

    private List<mseeagebean> readxls(HSSFWorkbook hssfWorkbook) {
        if (null != hssfWorkbook) {
            // 循环sheet表单
            for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) {
                HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(numSheet);
                if (null == hssfSheet) {
                    continue;
                }
                // 循环读行，第一行为标题栏所以从1开始
                for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
                    HSSFRow hssfRow = hssfSheet.getRow(rowNum);
                    if (null != hssfRow) {
                        //循环读列
                        for (int ColumnNum = 0; ColumnNum <= hssfSheet.getRow(rowNum).getPhysicalNumberOfCells(); ColumnNum++) {
                            mseeagebean mseeagebean = new mseeagebean();
                            HSSFCell hssfCell = hssfRow.getCell(ColumnNum);
                            String cellValue = "";
                            if (null != hssfCell) {
                                // 以下是判断数据的类型
                                switch (hssfCell.getCellTypeEnum()) {
                                    case STRING:
                                        cellValue = hssfCell.getRichStringCellValue().getString();
                                        mseeagebean.setString(cellValue);
                                        break;
                                    case NUMERIC:
                                        if ("General".equals(hssfCell.getCellStyle().getDataFormatString())) {
                                            DecimalFormat df = new DecimalFormat("0");
                                            cellValue = df.format(hssfCell.getNumericCellValue());
                                        } else if ("m/d/yy".equals(hssfCell.getCellStyle().getDataFormatString())) {
                                            SimpleDateFormat sdf = new SimpleDateFormat("m/d/yy");
                                            cellValue = sdf.format(hssfCell.getDateCellValue());
                                        } else {
                                            //cellValue = df.format(hssfCell.getNumericCellValue());
                                        }
                                        break;
                                    case BOOLEAN:
                                        //boolean a = hssfCell.getBooleanCellValue();
                                        break;
                                    case BLANK:
                                        cellValue = "";
                                        break;
                                    default:
                                        cellValue = hssfCell.toString();
                                        break;
                                }
                            }
                            list.add(mseeagebean);
                        }
                    }
                }
            }
        }
        return list;
    }


    //判断文件是否存在
    private boolean isfileexit(String execlpath) {
        File file = new File(execlpath);
        if (null == file || !file.exists()) {
            Toast.makeText(context, "文件不存在！", Toast.LENGTH_LONG).show();
            return false;
        } else if (!execlpath.endsWith("xls") && !execlpath.endsWith("xlsx")) {
            Toast.makeText(context, "不是execl文件！", Toast.LENGTH_LONG).show();
            return false;
        } else {
            return true;
        }
    }
}
*/
